package com.yyy.trans.controller;

import com.yyy.trans.aspect.ApiOperationLog;
import com.yyy.trans.service.UserService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

@RestController
@RequestMapping("/trans")
public class TransTestController {

    @Autowired
    private UserService userService;

    @PostMapping("/wrong1")
    @ApiOperation(value = "运行时异常事务传播")
    @ApiOperationLog(description = "运行时异常事务传播")
    public int wrong1(@RequestParam("name") String name) {
        return userService.createUserWrong1(name);
    }

    @PostMapping("/wrong2")
    @ApiOperation(value = "受检时异常事务传播")
    @ApiOperationLog(description = "受检时异常事务传播")
    public int wrong2(@RequestParam("name") String name) throws IOException {
        return userService.createUserWrong2(name);
    }

}
